package service;

import dao.PetDao;
import dao.PetDaoMysqlimpl;
import dao.PetDaoOracleimpl;
import entity.Pet;
import factory.PetDaoFactory;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("petService")
public class PetServiceimpl implements PetService{
    @Resource(type = PetDaoOracleimpl.class)
    private PetDao petDao;

    public PetDao getPetDao() {
        return petDao;
    }

    public void setPetDao(PetDao petDao) {
        this.petDao = petDao;
    }

    @Override
    public boolean save(Pet pet) {
        int rows = petDao.insert(pet);
        delay(3000);
        return rows>0;
    }

    @Override
    public boolean modify(Pet pet) {
        delay(2000);
        return false;
    }

    @Override
    public boolean del(Integer id) {
        delay(1000);
        return false;
    }
    public void delay(int time){
        try{
            Thread.sleep(time);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
